import java.util.*;

public class Main
{
    public static void main(String []args)
    {
	Locale.setDefault(Locale.US);
	Scanner in = new Scanner(System.in);
	int len = in.nextInt();
	double p = in.nextDouble();
	Random rnd = new Random();
	int geom[] = new int [len];
	for (int i = 0; i < len; ++i)
	    geom[i] = (int) (Math.log(rnd.nextDouble()) / Math.log(1 - p));
	double e = 0, d = 0;
	for (int i = 0; i < len; ++i)
	    e += geom[i];
	e /= len;
	for (int i = 0; i < len; ++i)
	    d += Math.pow(geom[i] - e, 2.0);
	d /= (len - 1);
	System.out.println(e + "\t" + (1 - p) / p);
	System.out.println(d + "\t" + (1 - p) / (p * p));

    }
}